﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UploadSinglePhoto.ascx.cs" Inherits="Besture.UI.Admin.Control.UploadSinglePhoto" %>
<script language="javascript" type="text/javascript">
    /*上传图片*/
    $(document).ready(function () {
        /*模板图片控件*/
        setTimeout(function () {
            $("#uploadify<%=PhotoDivID %>").uploadify({
                'swf': '/Admin/PlugIn/jquery.uploadify/uploadify.swf',
                'method': 'get',
                'uploader': '/Admin/Control/UploadPhoto.aspx',
                'formData': { 'FolderPath': '<%=FolderPath %>', 'NeedThumbnail': '<%=NeedThumbnail %>', 'ThumbnailFolderPath': '<%=ThumbnailFolderPath %>', 'ThumbnailWidth': '<%=ThumbnailWidth %>', 'ThumbnailHeight': '<%=ThumbnailHeight %>' },
                'fileObjName': "ProductPhotoFile",
                'folder': '/Upload/',
                'queueID': 'fileQueue<%=PhotoDivID %>',
                'auto': true,
                'multi': false,
                'fileTypeExts': "*.jpg;*.png;*.gif;",
                'fileTypeDesc': 'Web Image Files (.JPG, .GIF, .PNG)',
                'buttonImage': '/Admin/PlugIn/jquery.uploadify/browse-btn.png',
                'cancelImg': '/Admin/PlugIn/jquery.uploadify/uploadify-cancel.png',
                'width': 120,
                'height': 30,
                'wmode': 'transparent',
                'onUploadSuccess': function (file, data, response) {//上传完成时触发（每个文件触发一次）
                    if (!response) {
                        alert("网络异常，上传失败！");
                    } else {
                        if (data != "0") {
                            $("#<%=PhotoDivID %>_div").remove();
                            var serverDataArgs = data.split("|");
                            var imgUrl = serverDataArgs[0];
                            //添加图片地址同样赋值已存图片文本框，以便验证通过
                            $("#<%=txtImageUrl.ClientID %>").val(imgUrl);
                            var strhtml = "";
                            strhtml = strhtml + ("<div class='element' id='<%=PhotoDivID %>_div'>");
                            strhtml = strhtml + ("    <div>");
                            strhtml = strhtml + ("         <img src='<%=folderPathTemp %>" + imgUrl + "' alt='' />");
                            strhtml = strhtml + ("    </div>");
                            strhtml = strhtml + ("</div>");
                            $("#<%=PhotoDivID %>").html("");
                            $("#<%=PhotoDivID %>").append(strhtml);
                        }
                    }
                }

            });
        }, 10);
        
    });
</script>

<img src="<%=RequiredImageUrl %>" align="absMiddle" style="float: left; margin-top: 10px;" />
<div style="float: left">
    <!--上传模板图片控件-->
    <div style="height: 55px;min-width: 150px; border: 1px dashed #999999; background-color: #FFFFFF; padding: 5px 5px 5px 5px;">
        <span style="font-size: 95%; color: #666666" id="tipsSpan">※<%=Tips%></span>
        <!--上传模板图片控件-->
        <input type="file" name="uploadify<%=PhotoDivID %>" id="uploadify<%=PhotoDivID %>" />&nbsp;
    </div>
    <div id="fileQueue<%=PhotoDivID %>" style="width: 100%;">
    </div>
    <div class="uploadSinglePhotoDiv" id="<%=PhotoDivID %>">
        <%=InitText %>
    </div>
    <!--图片地址-->
    <asp:TextBox runat="server" ID="txtImageUrl" Style="display: none"></asp:TextBox>
</div>